import React from 'react'
import { View, TextInput } from 'react-native'
import { Controller, useFieldArray } from 'react-hook-form'
import { Text } from '@rneui/themed'
import { leaveStyles } from '../../../styles/leaveStyles'

interface OtherFormProps {
    control: any
    watch: any
    _isEditMode?: boolean
    _onMarkForDeletion?: (itemId: string) => void
    _getValues?: any
}

export const OtherForm: React.FC<OtherFormProps> = ({
    control,
    watch: _watch,
    _isEditMode,
    _onMarkForDeletion,
    _getValues
}) => {
    const otherArray = useFieldArray({ control, name: "otherItems" })

    return (
        <View style={leaveStyles.reasonFormContainer}>
            {otherArray.fields.map((field, index) => (
                <View key={field.id} style={leaveStyles.itemContainer}>
                    <Text style={leaveStyles.subLabel}>描述</Text>
                    <Controller
                        control={control}
                        name={`otherItems.${index}.description`}
                        render={({ field: { onChange, value } }) => (
                            <TextInput
                                style={leaveStyles.textArea}
                                value={value}
                                onChangeText={onChange}
                                placeholder="请描述其他事由"
                                multiline={true}
                                numberOfLines={3}
                                textAlignVertical="top"
                            />
                        )}
                    />
                </View>
            ))}
        </View>
    )
}
